package com.eliza.music.view.music.find

import androidx.compose.foundation.background
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.eliza.music.compoment.music.PlaylistView
import com.eliza.music.compoment.music.SongView.BigSongCardList
import com.eliza.music.model.tmp.BasicTitles
import com.eliza.music.model.tmp.DataCategory
import com.eliza.music.model.tmp.ListDataCategory
import com.eliza.music.model.tmp.PlaylistListBig
import com.eliza.music.ui.theme.PaddingSize
import com.eliza.music.view.music.mine.BasicTitle

@Preview
@Composable
private fun FindPageXPreview() {
    FindPageX.Route()
}

object FindPageX {
    @Composable
    fun Route() {
        Screen()
    }

    @Composable

    fun Screen() {
        LazyColumn(
            modifier = Modifier
                .background(Color.White)
                .padding(PaddingSize.Normal.size)
        ) {
            item {
                TopSelection(BasicTitles)
                BigSongCardList(
                    modifier = Modifier.height(200.dp), DataCategory(
                        PlaylistListBig.subList(
                            0, PlaylistListBig.size / 2
                        )
                    )
                )
            }
            items(ListDataCategory) {
                PlaylistView.CardByRow(data = it)
            }

        }
    }

    @Composable
    fun TopSelection(data: List<BasicTitle>, modifier: Modifier = Modifier) {
        Row(
            modifier = Modifier
                .background(Color.Transparent)
                .fillMaxWidth()
                .horizontalScroll(rememberScrollState())
                .then(modifier),
            verticalAlignment = Alignment.CenterVertically,
            horizontalArrangement = Arrangement.SpaceEvenly
        ) {
            data.forEach {
                TextButton(
                    modifier = Modifier,
                    shape = RoundedCornerShape(PaddingSize.Normal.size),
                    onClick = { /*TODO*/ },
                    contentPadding = PaddingValues(0.dp)
                ) {
                    Text(
                        text = it.title,
                        fontSize = 15.sp,
                        fontFamily = FontFamily.Monospace,
                        fontWeight = FontWeight.W700,
                        color = Color.Black.copy(0.8f),
                    )

                }
            }
        }
    }


}
